package org.example.springbootdemo;

import org.springframework.web.bind.annotation.*;

/**
 * @author: Themberfue
 * @date: 2024/11/25 20:35
 * @description:
 */
@RequestMapping("/User2")
@RestController
public class UserController2 {
    // 既支持所有请求类型
    @RequestMapping("/user1")
    public String user1() {
        return "Hello user1(All Types)";
    }

    // 只能支持 GET 请求
    @RequestMapping(value = "/user2", method = RequestMethod.GET)
    public String user2() {
        return "Hello user2(Only GET)";
    }

    // 只能支持 POST 请求
    @RequestMapping(value = "/user3", method = RequestMethod.POST)
    public String user3() {
        return "Hello user3(Only POST)";
    }

    // 只能支持 GET 请求
    @GetMapping("/user4")
    public String user4() {
        return "Hello user4(Only GET)";
    }

    // 只能支持 POST 请求
    @PostMapping("/user5")
    public String user5() {
        return "Hello user5(Only POST)";
    }

    @RequestMapping(value = "/user6", method = {RequestMethod.GET, RequestMethod.POST})
    public String user6() {
        return "Hello user6(Both GET and POST)";
    }
}
